﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tester.Interface;
using Tester.Tests;

namespace Tester {
    public class Program {

        private static List<ITester> _testers = new List<ITester>();

        static void Main(string[] args) {
            RegisterTesters();
            RunTesters();
            AnalyseErrors();
        }

        static void RegisterTesters() {
            _testers.Add(new LogBookParserTester());
            _testers.Add(new CrawlerTester());

        }

        static void RunTesters() {
            foreach(ITester tester in _testers) {
                tester.Run();
            }
        }

        static void AnalyseErrors() {
            bool hasErrors = false;
            foreach (ITester tester in _testers) {
                foreach (string error in tester.Errors) {
                    Console.Error.WriteLine(error);
                    hasErrors = true;
                }
            }
            if (!hasErrors) {
                Console.WriteLine("All tests passed successfully!");
            }
        }
    }
}
